import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

//修改
public class Demo2 {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource=new MysqlDataSource();
        ((MysqlDataSource) dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/test_rjw?CharacterEncoding=utf8&useSSL=false");
        ((MysqlDataSource) dataSource).setUser("root");
        ((MysqlDataSource) dataSource).setPassword("200483");

        Connection connection=dataSource.getConnection();

        String sql="update student set id = 1 where id = 100";
        PreparedStatement statement=connection.prepareStatement(sql);

        int n = statement.executeUpdate();
        System.out.println(n);

        statement.close();
        connection.close();

    }
}
